using System;
using System.ComponentModel;
using System.Linq.Expressions;

namespace FluentBinding.WinForms
{
    /// <summary>
    /// Represent fluent interface for adding entities implementing INotifyPropertyChanged
    /// which affect current binding
    /// </summary>
    /// <typeparam name="E">Type of the root entity</typeparam>
    /// <typeparam name="P">Type of the property in the data-bound control</typeparam>
    public interface ISupportEntityNotifications<E, P>
    {
        #region Public methods

        /// <summary>
        /// By default binding unit does not handle updates of entities which are not result of the binding
        /// 
        /// If such updates are possible (e.g. some background thread updates entities), than such entities
        /// should be specified explicitely using lambda expression        
        /// 
        /// Every entity can raise INotifyPropertyChanged.PropertyChanged for any of its properties
        /// In order to filter out not relevant updates properties can be specified using second parameter
        /// using lambda expression
        /// </summary>
        /// <example>
        /// ...  
        ///     .To(x => x.Country.Name, (x, value) => x.Country.Name = value)
        ///     .WithNotifier(x => x.Country, c => c.Name);
        /// </example>
        /// <typeparam name="N">Type of the entity which supports INotifyPropertyChanged</typeparam>
        IPropertyBinding<E, P> WithNotifier<N>(Func<E, N> notifier,
                                               params Expression<Func<N, object>>[] notifierPropertyExpressions)
            where N : INotifyPropertyChanged;

        #endregion
    }
}